<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Cines extends CI_Controller {

    public function __construct() {
        parent::__construct();

        $this->load->helper('url');
        $this->load->model('cines_model');
        $this->load->model('salas_model');
        $this->load->model('peliculas_model');
     
    }

    public function index() {

   
        $this->listado();
        
    }

    public function listado() {
        $data['salas'] = $this->salas_model->get_salas(); 
        $data['cines'] = $this->cines_model->get_cines();
        $data['title'] = "Viendo cines de " . $data['cines'][0]['provincia'];


        if (count($data['cines']) > 0) {

            $this->load->view('templates/header', $data);

            $this->load->view('cines/single', $data);
          //  $this->load->view('cines/listado', $data); //añado lisat de salas
            $this->load->view('templates/footer', $data);
        } else {
            echo "vista no encontrada";
            show_404();
        }
/*
        echo "<pre>";
        print_r($data);
        echo "</pre>";
 */   
  }
 

    public function cine($slug) {//cambnio de salas a cines

        $data['salas'] = $this->salas_model->get_salas($slug);
        $data['cines'] = $this->salas_model->get_cine_sala($slug);
        $data['cines'] = $this->salas_model->get_cine_sala($slug);
        //$data['peliculas'] = $this->peliculas_model->get_peliculas();
        
        $data['title'] = "Viendo salas de: " . $slug;

        if (count($data['salas'] > 0)) {
            $this->load->view('templates/header', $data);
  
            $this->load->view('cines/listado_salas', $data); 
            $this->load->view('templates/footer', $data);
        } else {
            echo "vista no encontrada salas";
            show_404();
        }
    }

    
    
    public function cine_info($slug) {//cambnio de salas a cines

        $data['salas'] = $this->salas_model->get_salas($slug);
        $data['cines'] = $this->salas_model->get_cine_sala($slug);
        $data['cines'] = $this->salas_model->get_cine_sala($slug);
        $data['cines'] = $this->cines_model->get_info_cines();
      
        $data['title'] = "Viendo salas de: " . $slug;

        if (count($data['salas'] > 0)) {
            $this->load->view('templates/header', $data);
         
            $this->load->view('cines/localizacion', $data);
            $this->load->view('templates/footer', $data);
        } else {
            echo "vista no encontrada salas";
            show_404();
        }
    }

    
    /*
      echo "<pre>";
      print_r($data);
      echo "</pre>";
     */

 

}
